<!-- $Id -->

{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,../js/transport.org.js,validator.js"}
{if $step eq "consignee"}
{insert_scripts files="../js/region.js"}
{/if}

{if $step eq "user"}
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkUser()">
<div class="main-div" style="padding: 15px">
  <label><input type="radio" name="anonymous" value="1" checked /> {$lang.anonymous}</label><br />
  <label><input type="radio" name="anonymous" value="0" id="user_useridname" /> {$lang.by_useridname}</label>
  <input name="keyword" type="text" value="" />
  <input type="button" class="button" name="search" value="{$lang.button_search}" onclick="searchUser();" />
  <select name="user"></select>
  <p>{$lang.notice_user}</p>
</div>
<div style="text-align:center">
  <p>
    <input name="submit" type="submit" class="button" value="{$lang.button_next}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</div>
</form>

{elseif $step eq "goods"}
<form name="theForm" action="order.php?act=step_post&step=edit_goods&order_id={$order_id}&step_act={$step_act}" method="post">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th scope="col">{$lang.goods_name}</th>
    <th scope="col">{$lang.goods_sn}</th>
    <th scope="col">{$lang.goods_price}</th>
	<th scope="col">手机专享价格</th>
    <th scope="col">{$lang.goods_number}</th>
    <th scope="col">{$lang.goods_attr}</th>
    <th scope="col">{$lang.subtotal}</th>
    <th scope="col">{$lang.handler}</th>
  </tr>
  {foreach from=$goods_list item=goods name="goods"}
  <tr>
    <td>
    {if $goods.goods_id gt 0 && $goods.extension_code neq 'package_buy'}
    <a href="#" onclick="getGoodsInfo({$goods.goods_id});">{$goods.goods_name}</a>
    {elseif $goods.goods_id gt 0 && $goods.extension_code eq 'package_buy'}
    {$goods.goods_name}
    {/if}
    </td>
    <td>{$goods.goods_sn}<input name="rec_id[]" type="hidden" value="{$goods.rec_id}" /></td>
    <td><input name="goods_price[]" type="text" style="text-align:right" value="{$goods.goods_price}" size="10" />
        <input name="goods_id[]" type="hidden" style="text-align:right" value="{$goods.goods_id}" size="10" /></td>
    <!--  //手机专享价格 app  -->
	<td><input name="exclusive[]" type="text" style="text-align:right" value="{$goods.exclusive}" size="10" />
	 <!--  //手机专享价格 app  -->
	<td><input name="goods_number[]" type="text" style="text-align:right" value="{$goods.goods_number}" size="6" /></td>
    <td><textarea name="goods_attr[]" cols="30" rows="{$goods.rows}">{$goods.goods_attr}</textarea></td>
    <td align="right">{$goods.subtotal}</td>
    <td><a href="javascript:confirm_redirect(confirm_drop, 'order.php?act=process&func=drop_order_goods&rec_id={$goods.rec_id}&step_act={$step_act}&order_id={$order_id}')">{$lang.drop}</a></td>
  </tr>
  {/foreach}
  <tr>
    <td colspan="5"><span class="require-field">{$lang.price_note}</span></td>
    <td align="right"><strong>{$lang.label_total}</strong></td>
    <td align="right">{$goods_amount}</td>
    <td>{if $smarty.foreach.goods.total > 0}<input name="edit_goods"  class="button" type="submit" value="{$lang.update_goods}" />{/if}
    <input name="goods_count" type="hidden" value="{$smarty.foreach.goods.total}" /></td>
  </tr>
</table>
</div>
</form>

<form name="goodsForm" action="order.php?act=step_post&step=add_goods&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return addToOrder()">
<p>
  {$lang.search_goods}
  <input type="text" name="keyword" value="" />
  <input type="button" name="search" class="button" value="{$lang.button_search}" onclick="searchGoods();" />
  <select name="goodslist" onchange="getGoodsInfo(this.value)"></select>
</p>
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th width="100">{$lang.goods_name}</th>
    <td id="goods_name">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.goods_sn}</th>
    <td id="goods_sn">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.category}</th>
    <td id="goods_cat">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.brand}</th>
    <td id="goods_brand">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.goods_price}</th>
    <td id="add_price">&nbsp;</td>
  </tr>
  <tr>
  <!--  //手机专享价格 app  -->
    <th>手机专享价格</th>
    <td id="add_exclusive">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.goods_attr}<input type="hidden" name="spec_count" value="0" /></th>
    <td id="goods_attr">&nbsp;</td>
  </tr>
  <tr>
    <th>{$lang.goods_number}</th>
    <td><input name="add_number" type="text" value="1" size="10"></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input name="add_goods" type="submit"  class="button" value="{$lang.add_to_order}" /></td>
  </tr>
</table>
</div>
</form>
<form action="order.php?act=step_post&step=goods&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkGoods()">
  <p align="center">
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>

{elseif $step eq "consignee"}
{insert_scripts files="../js/transport.org.js,../js/region.js"}
<script type="text/javascript">
region.isAdmin=true;
</script>
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkConsignee()">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  {if $address_list}
  <tr>
    <th align="left">{$lang.address_list}</th>
    <td><select onchange="loadAddress(this.value)"><option value="0" selected>{$lang.select_please}</option>
      {foreach from=$address_list item=address}<option value="{$address.address_id}" {if $smarty.get.address_id eq $address.address_id}selected{/if}>{$address.consignee|escape} {$address.email} {$address.address|escape} {$address.tel|escape}</option>{/foreach}
    </select></td>
  </tr>
  {/if}
  <tr>
    <th width="150" align="left">{$lang.label_consignee}</th>
    <td><input name="consignee" type="text" value="{$order.consignee}" />
      {$lang.require_field}</td>
  </tr>
  {if $exist_real_goods}
  <tr>
    <th align="left">{$lang.label_area}</th>
    <td><select name="country" id="selCountries" onChange="region.changed(this, 1, 'selProvinces')">
        <option value="0" selected="true">{$lang.select_please}</option>
        {foreach from=$country_list item=country}
        <option value="{$country.region_id}" {if $order.country eq $country.region_id}selected{/if}>{$country.region_name}</option>
        {/foreach}
      </select> <select name="province" id="selProvinces" onChange="region.changed(this, 2, 'selCities')">
        <option value="0">{$lang.select_please}</option>
        {foreach from=$province_list item=province}
        <option value="{$province.region_id}" {if $order.province eq $province.region_id}selected{/if}>{$province.region_name}</option>
        {/foreach}
      </select> <select name="city" id="selCities" onchange="region.changed(this, 3, 'selDistricts')">
          <option value="0">{$lang.select_please}</option>
          <!-- {foreach from=$city_list item=city} -->
          <option value="{$city.region_id}" {if $order.city eq $city.region_id}selected{/if}>{$city.region_name}</option>
          <!-- {/foreach} -->
        </select>
        <select name="district" id="selDistricts">
          <option value="0">{$lang.select_please}</option>
          <!-- {foreach from=$district_list item=district} -->
          <option value="{$district.region_id}" {if $order.district eq $district.region_id}selected{/if}>{$district.region_name}</option>
          <!-- {/foreach} -->
        </select>
        {$lang.require_field}</td>
  </tr>
  {/if}
  <tr>
    <th align="left">{$lang.label_email}</th>
    <td><input name="email" type="text" value="{$order.email}" size="40" />
    {$lang.require_field}</td>
  </tr>
  {if $exist_real_goods}
  <tr>
    <th align="left">{$lang.label_address}</th>
    <td><input name="address" type="text" value="{$order.address}" size="40" />
    {$lang.require_field}</td>
  </tr>
  <tr>
    <th align="left">{$lang.label_zipcode}</th>
    <td><input name="zipcode" type="text" value="{$order.zipcode}" /></td>
  </tr>
  {/if}
  <tr>
    <th align="left">{$lang.label_tel}</th>
    <td><input name="tel" type="text" value="{$order.tel}" />
    </td>
  </tr>
  <tr>
    <th align="left">{$lang.label_mobile}</th>
    <td><input name="mobile" type="text" value="{$order.mobile}" /></td>
  </tr>
  {if $exist_real_goods}
<!--  <tr>
    <th align="left">{$lang.label_sign_building}</th>
    <td><input name="sign_building" type="text" value="{$order.sign_building}" size="40" /></td>
  </tr>-->
  <tr>
    <th align="left">{$lang.label_best_time}</th>
    <td><input name="best_time" type="text" value="{$order.best_time}" size="40" /></td>
  </tr>
  {/if}
</table>
</div>

<div align="center">
  <p>
    {if $step_act eq "add"}{if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}{/if}
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</div>
</form>

{elseif $step eq "shipping"}
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkShipping()">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">&nbsp;</th>
    <th width="25%">{$lang.name}</th>
    <th>{$lang.desc}</th>
    <th width="15%">{$lang.shipping_fee}</th>
    <th width="15%">{$lang.free_money}</th>
  <th width="15%">{$lang.insure}</th>
  </tr>
  {foreach from=$shipping_list item=shipping}
  <tr>
    <td><input name="shipping" type="radio" value="{$shipping.shipping_id}" {if $order.shipping_id eq $shipping.shipping_id}checked{/if} onclick="" /></td>
    <td>{$shipping.shipping_name}</td>
    <td>{$shipping.shipping_desc}</td>
    <td><div align="right">{$shipping.format_shipping_fee}</div></td>
    <td><div align="right">{$shipping.free_money}</div></td>
  <td><div align="right">{$shipping.insure}</div></td>
  </tr>
  {/foreach}
  {if $pickup_point_list}
	<tr>
    <th width="5%">&nbsp;</th>
    <th width="25%">门店自提点列表</th>
    <th colspan="4">详细描述</th>
    </tr>
  {foreach from=$pickup_point_list item=shipping}
  <tr>
    <td><input name="pickup_point" type="radio" value="{$shipping.id}" {if $order.pickup_point eq $shipping.id}checked{/if} onclick="" /></td>
    <td>{$shipping.shop_name}</td>
    <td colspan="4">地址:{$shipping.address}&nbsp;&nbsp;联系人:{$shipping.contact}&nbsp;&nbsp;联系方式:{$shipping.phone}</td>
    </tr>
  {/foreach}
  <tr>
  {/if}
</table>
</div>

<p align="right"><input name="insure" type="checkbox" value="1" {if $order.insure_fee > 0}checked{/if} />
{$lang.want_insure}</p>

  <p align="center">
    {if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>

{elseif $step eq "payment"}
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkPayment()">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">&nbsp;</th>
    <th width="20%">{$lang.name}</th>
    <th>{$lang.desc}</th>
    <th width="15%">{$lang.pay_fee}</th>
  </tr>
  {foreach from=$payment_list item=payment}
  <tr>
    <td><input type="radio" name="payment" value="{$payment.pay_id}" {if $order.pay_id eq $payment.pay_id}checked{/if} /></td>
    <td>{$payment.pay_name}</td>
    <td>{$payment.pay_desc}</td>
    <td align="right">{$payment.pay_fee}</td>
  </tr>
  {/foreach}
</table>
</div>
  <p align="center">
    {if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>

{elseif $step eq "other"}
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post">
<div class="list-div">
{if $exist_real_goods and ($pack_list or $card_list)}
<table cellpadding="3" cellspacing="1">
  {if $pack_list}
  <tr>
    <th colspan="4" scope="col">{$lang.select_pack}</th>
    </tr>
  <tr>
    <td width="5%" scope="col">&nbsp;</td>
    <td width="35%" scope="col"><div align="center"><strong>{$lang.name}</strong></div></td>
    <td width="22%" scope="col"><div align="center"><strong>{$lang.pack_fee}</strong></div></td>
    <td width="22%" scope="col"><div align="center"><strong>{$lang.free_money}</strong></div></td>
    </tr>
  <tr>
    <td><input type="radio" name="pack" value="0" {if $order.pack_id eq 0}checked{/if} /></td>
    <td>{$lang.no_pack}</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
  {foreach from=$pack_list item=pack}
  <tr>
    <td><input type="radio" name="pack" value="{$pack.pack_id}" {if $order.pack_id eq $pack.pack_id}checked{/if} /></td>
    <td>{$pack.pack_name}</td>
    <td><div align="right">{$pack.format_pack_fee}</div></td>
    <td><div align="right">{$pack.format_free_money}</div></td>
    </tr>
  {/foreach}
  {/if}
  {if $card_list}
  <tr>
    <th colspan="4" scope="col">{$lang.select_card}</th>
    </tr>
  <tr>
    <td scope="col">&nbsp;</td>
    <td scope="col"><div align="center"><strong>{$lang.name}</strong></div></td>
    <td scope="col"><div align="center"><strong>{$lang.card_fee}</strong></div></td>
    <td scope="col"><div align="center"><strong>{$lang.free_money}</strong></div></td>
    </tr>
  <tr>
    <td><input type="radio" name="card" value="0" {if $order.card_id eq 0}checked{/if} /></td>
    <td>{$lang.no_card}</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
  {foreach from=$card_list item=card}
  <tr>
    <td><input type="radio" name="card" value="{$card.card_id}" {if $order.card_id eq $card.card_id}checked{/if} /></td>
    <td>{$card.card_name}</td>
    <td><div align="right">{$card.format_card_fee}</div></td>
    <td><div align="right">{$card.format_free_money}</div></td>
    </tr>
  {/foreach}
  {/if}
</table>
{/if}
</div><br />
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  {if $exist_real_goods}
  {if $card_list}
  <tr>
    <th>{$lang.label_card_message}</th>
    <td><textarea name="card_message" cols="60" rows="3">{$order.card_message}</textarea></td>
  </tr>
  {/if}
   <!--增值税发票_删除_START_www.68ecshop.com-->
  <!--<tr>
    <th>{$lang.label_inv_type}</th>
    <td><input name="inv_type" type="text" id="inv_type" value="{$order.inv_type}" size="40" /></td>
  </tr>
  <tr>
    <th>{$lang.label_inv_payee}</th>
    <td><input name="inv_payee" value="{$order.inv_payee}" size="40" text="text" /></td>
  </tr>
  <tr>
    <th>{$lang.label_inv_content}</th>
    <td><input name="inv_content" value="{$order.inv_content}" size="40" text="text" /></td>
  </tr>-->
  <!--增值税发票_删除_END_www.68ecshop.com-->
  {/if}
  <tr>
    <th>{$lang.label_postscript}</th>
    <td><textarea name="postscript" cols="60" rows="3">{$order.postscript}</textarea></td>
  </tr>
  <tr>
    <th>{$lang.label_how_oos}</th>
    <td><input name="how_oos" type="text" value="{$order.how_oos}" size="40" /></td>
  </tr>
  <tr>
    <th>{$lang.label_to_buyer}</th>
    <td><textarea name="to_buyer" cols="60" rows="3">{$order.to_buyer}</textarea></td>
  </tr>
</table>
</div>
  <p align="center">
    {if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>

{elseif $step eq "money"}
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th width="120">{$lang.label_goods_amount}</th>
    <td width="150">{$order.formated_goods_amount}</td>
  <th width="120">{$lang.label_discount}</th>
    <td><input name="discount" type="text" id="discount" value="{$order.discount}" size="15" /></td>
  </tr>
  <tr>
    <th>{$lang.label_tax}</th>
    <td><input name="tax" type="text" id="tax" value="{$order.tax}" size="15" /></td>
    <th>{$lang.label_order_amount}</th>
    <td>{$order.formated_total_fee}</td>
  </tr>
  <tr>
    <th>{$lang.label_shipping_fee}</th>
    <td>{if $exist_real_goods}<input name="shipping_fee" type="text" value="{$order.shipping_fee}" size="15">{else}0{/if}</td>
  <th width="120">{$lang.label_money_paid}</th>
    <td>{$order.formated_money_paid} </td>
  </tr>
    <tr>
        <th>{$lang.label_pay_fee}</th>
        <td><input name="pay_fee" type="text" value="{$order.pay_fee}" size="15"></td>
        <th>{$lang.label_surplus}</th>
        <td>{if $order.user_id >0}
            <input name="surplus" type="text" value="{$order.surplus}" size="15">
            {/if} {$lang.available_surplus}{$available_user_money|default:0}</td>
    </tr>
    <tr>
        <th>{if $order.order_amount >= 0} {$lang.label_money_dues} {else} {$lang.label_money_refund} {/if}</th>
        <td>{$order.formated_order_amount}</td>
        <td colspan="2">&nbsp;</td>
    </tr>
    <!--
  <tr>
    <th>{$lang.label_insure_fee}</th>
    <td>{if $exist_real_goods}<input name="insure_fee" type="text" value="{$order.insure_fee}" size="15">{else}0{/if}</td>
  <th>{$lang.label_surplus}</th>
    <td>{if $order.user_id >0}
        <input name="surplus" type="text" value="{$order.surplus}" size="15">
  {/if} {$lang.available_surplus}{$available_user_money|default:0}</td>
  </tr>
  <tr>
    <th>{$lang.label_pay_fee}</th>
    <td><input name="pay_fee" type="text" value="{$order.pay_fee}" size="15"></td>
  <th>{$lang.label_integral}</th>
    <td>{if $order.user_id > 0}
        <input name="integral" type="text" value="{$order.integral}" size="15">
  {/if} {$lang.available_integral}{$available_pay_points|default:0}</td>
  </tr>
  -->
 <!-- <tr>
    <th>{$lang.label_pack_fee}</th>
    <td>{if $exist_real_goods}
      <input name="pack_fee" type="text" value="{$order.pack_fee}" size="15">
      {else}0{/if}</td>-->
       <!--<th>{$lang.label_card_fee}</th>
    <td>{if $exist_real_goods}
      <input name="card_fee" type="text" value="{$order.card_fee}" size="15">
      {else}0{/if}</td>
     
  </tr>-->
    <!--
  <tr>
    <th>{$lang.label_bonus}</th>
    <td>
      <select name="bonus_id">
        <option value="0" {if $order.bonus_id eq 0}selected{/if}>{$lang.select_please}</option>

          {foreach from=$available_bonus item=bonus}

        <option value="{$bonus.bonus_id}" {if $order.bonus_id eq $bonus.bonus_id}selected{/if} money="{$bonus.type_money}">{$bonus.type_name} - {$bonus.type_money}</option>

          {/foreach}

      </select>    </td>
     <th>{if $order.order_amount >= 0} {$lang.label_money_dues} {else} {$lang.label_money_refund} {/if}</th>
    <td>{$order.formated_order_amount}</td>
   
  </tr>
    -->
</table>
</div>
  <p align="center">
    {if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}
    <input name="finish" type="submit" class="button" value="{$lang.button_finish}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>

{elseif $step eq "invoice"}
<!--增值税发票_删除_START_www.68ecshop.com-->
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkShipping()">
<div class="list-div">
<table cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">&nbsp;</th>
    <th width="25%">{$lang.name}</th>
    <th>{$lang.desc}</th>
    </tr>
  {foreach from=$shipping_list item=shipping}
  <tr>
    <td><input name="shipping" type="radio" value="{$shipping.shipping_id}" {if $order.shipping_id eq $shipping.shipping_id}checked{/if} onclick="" /></td>
    <td>{$shipping.shipping_name}</td>
    <td>{$shipping.shipping_desc}</td>
    </tr>
  {/foreach}
  {if $pickup_point_list}
	<tr>
    <th width="5%">&nbsp;</th>
    <th width="25%">门店自提点列表</th>
    <th>详细描述</th>
    </tr>
  {foreach from=$pickup_point_list item=shipping}
  <tr>
    <td><input name="pickup_point" type="radio" value="{$shipping.id}" {if $order.pickup_point eq $shipping.id}checked{/if} onclick="" /></td>
    <td>{$shipping.shop_name}</td>
    <td>地址:{$shipping.address}&nbsp;&nbsp;联系人:{$shipping.contact}&nbsp;&nbsp;联系方式:{$shipping.phone}</td>
    </tr>
  {/foreach}
  <tr>
  {/if}
    <td colspan="3"><strong>{$lang.shipping_note}</strong></td>
    </tr>
  <tr>
    <td colspan="3"><a href="javascript:showNotice('noticeinvoiceno');" title="{$lang.form_notice}"><img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a><strong>{$lang.label_invoice_no}</strong><input name="invoice_no" type="text" value="{$order.invoice_no}" size="30"/><br/><span class="notice-span" id="noticeinvoiceno" style="display:block;">{$lang.invoice_no_mall}</span></td>
  </tr>
</table>
</div>

  <p align="center">
    {if $step_act eq "add"}<input type="button" value="{$lang.button_prev}" class="button" onclick="history.back()" />{/if}
    <input name="{if $step_act eq 'add'}next{else}finish{/if}" type="submit" class="button" value="{if $step_act eq 'add'}{$lang.button_next}{else}{$lang.button_submit}{/if}" />
    <input type="button" value="{$lang.button_cancel}" class="button" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
  </p>
</form>
<!--增值税发票_删除_END_www.68ecshop.com-->
<!--增值税发票_添加_START_www.68ecshop.com-->
<script lang='javascript' type='text/javascript'>
  function $(id)
  {
    return document.getElementById(id);
  }
</script>
<!--编辑发票-->
{if $step_detail eq 'edit'}
{insert_scripts files="../js/region.js"}
<script lang='javascript' type='text/javascript'>
  region.isAdmin = true;
 function check_input()
  {
    var arr = new Array();
    var key = '';
    var inv_content = '';
    if($('inv_type').value == 'normal_invoice')
    {
      arr = new Array();
      key = 'n';
    }
    else if($('inv_type').value == 'vat_invoice')
    {
      arr = new Array('selProvinces','selCities','selDistricts');
      key = 'v';
    }

    var stop = 'no';

    for(var i=1;stop!='yes';i++)
    {
      if($('inv_input_'+key+i)==null)
      {
      stop = 'yes';
      }
      else
      {
        arr.push('inv_input_'+key+i);
      }
    }

    while(id = arr.pop())
    {
       if($(id).value =='' || $(id).value == '0')
        {
          alert('请输入全部信息！');
          return false;
        }
    }
    if(document.forms['theForm']['inv_payee_type'].value == 'vat_invoice')
    {
      if(document.forms['theForm']['inv_payee'].value == '' || document.forms['theForm']['inv_payee'].value == '0')
      {
        return false;
      }
    }

    if(document.forms['theForm']['inv_type'].value == 'normal_invoice')
    {
       inv_content = document.forms['theForm']['inv_content_n'].value;
    }
    else
    {
      inv_content = document.forms['theForm']['inv_content_v'].value;
    }

    var input = document.createElement('input');
    input.name = 'inv_content';
    input.type = 'hidden';
    input.value = inv_content;
    document.forms['theForm'].appendChild(input);
    return true;
  }

  function change_inv_type(inv_type)
  {
    if(inv_type.value == 'vat_invoice')
    {
      $('vat_invoice_tbody').style.display='';
      $('normal_invoice_tbody').style.display='none';
    }
    else
    {
      $('vat_invoice_tbody').style.display='none';
      $('normal_invoice_tbody').style.display='';
    }
  }

  function change_inv_payee_type(inv_payee_type)
  {
    if(inv_payee_type.value == 'individual')
    {
      $('inv_company_area').style.display='none';
    }
    else if(inv_payee_type.value == 'unit')
    {
      $('inv_company_area').style.display='';
    }
  }

  function check_taxpayer_id(t,id)
  {
      if(!check_preg_match(t.value,'taxpayer_id'))
      {
          document.getElementById(id).innerHTML='纳税人识别号错误，请检查！';
      }
      else
      {
          document.getElementById(id).innerHTML='';
      }
  }

  function check_bank_account(t,id)
  {
      if(!check_preg_match(t.value,'back_account'))
      {
          document.getElementById(id).innerHTML='银行账户含有非法字符！';
      }
      else
      {
          document.getElementById(id).innerHTML='';
      }
  }

  function check_phone_number(t,id)
  {
      if(!check_preg_match(t.value,'phone_number'))
      {
          document.getElementById(id).innerHTML='手机号码格式不正确！';
      }
      else
      {
          document.getElementById(id).innerHTML='';
      }
  }

  function check_preg_match(v,type)
  {
      var pattern = '';
      switch(type)
      {
          case 'taxpayer_id':
              pattern = '^[0-9]{15,}$';
              break;
          case 'back_account':
              pattern = '^[0-9A-z]+ *[0-9A-z]+$';
              break;
          case 'phone_number':
              pattern = '^1[0-9]{10}$';
      }
      var preg = new RegExp(pattern);
      return preg.test(v);
  }
</script>
<form id='invocie_form' name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return check_input()">
<div class='list-div'>
<table width='100%' cellspacing='1'>
<tr><th colspan='2'><strong>{$lang.inv_info}<strong><em style='font-size:12px;color:#f00;'>（所有信息为必填）</em></th><td colspan='1'>&nbsp</td></tr>
<tr>
<th width='13%'>{$lang.label_inv_type}</th>
<td width='40%'>
  <select id='inv_type' onchange='javascript:change_inv_type(this)' name='inv_type'>
    <option value='normal_invoice' {if $order.inv_type eq 'normal_invoice'}selected='selected'{/if}>{$lang.normal_invoice}</option>
    <option value='vat_invoice' {if $order.inv_type eq 'vat_invoice'}selected='selected'{/if}>{$lang.vat_invoice}</option>
  </select>
</td>
<td>&nbsp</td>
</tr>
<!--普通发票编辑选项-->
<tbody id='normal_invoice_tbody' {if $order.inv_type eq 'vat_invoice'}style='display:none'{/if}>
<tr><th>{$lang.label_inv_payee}</th>
<td>
    <select id='inv_input_n1' name = 'inv_payee_type' onchange='change_inv_payee_type(this)'>
      <option value='individual' {if $order.inv_payee_type eq 'individual'}selected='selected'{/if}>{$lang.individual}</option>
      <option value='unit' {if $order.inv_payee_type eq 'unit'}selected='selected'{/if}>{$lang.unit}</option>
    </select>
  </td>
  <td>&nbsp</td>
</tr>
<tr id='inv_company_area' {if $order.inv_payee_type neq 'unit'}style='display:none'{/if}>
  <th>{$lang.label_company_name1}</th>
  <td><input id='inv_company' name='inv_payee' type='text' {if $order.inv_payee_type eq 'unit'}value='{$order.inv_payee}' {/if}/></td>
  <td>&nbsp</td>
</tr>
<tr>
  <th>{$lang.label_inv_content}</th>
  <td>
  <select id='inv_input_n2' name='inv_content_n'>
    <option value=''>{$lang.please_select}</option>
    {foreach item=item key=key from=$cfg.invoice_content}
    <option value='{$item}' {if $item eq $order.inv_content}selected='selected'{/if}>{$item}</option>
    {/foreach}
  </select>
</td>
<td>&nbsp</td>
</tr>
</tbody>
<!--增值税发票编辑选项-->
<tbody id='vat_invoice_tbody' {if $order.inv_type neq 'vat_invoice'}style='display:none'{/if}>
<tr>
<th>{$lang.label_company_name1}</th>
<td><input id='inv_input_v1' name='vat_inv_company_name' value='{$order.vat_inv_company_name}'/></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_taxpayer_id}</th>
<td valign='center'><input id='inv_input_v2' name='vat_inv_taxpayer_id' value='{$order.vat_inv_taxpayer_id}' onblur='javascript:check_taxpayer_id(this,"taxpayer_notice")' style='float:left;'/><div id='taxpayer_notice' style='font-size:12px;color:#f00;float:left;'></div></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_registration_address}</th>
<td><input id='inv_input_v3' name='vat_inv_registration_address' value='{$order.vat_inv_registration_address}'/></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_registration_phone}</th>
<td><input id='inv_input_v4' name='vat_inv_registration_phone' value='{$order.vat_inv_registration_phone}'/></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_deposit_bank}</th>
<td><input id='inv_input_v5' name='vat_inv_deposit_bank' value='{$order.vat_inv_deposit_bank}'/></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_bank_account}</th>
<td><input id='inv_input_v6' name='vat_inv_bank_account' value='{$order.vat_inv_bank_account}' onblur='javascript:check_bank_account(this,"bank_account_notice")' style='float:left;'/><div id='bank_account_notice' style='font-size:12px;color:#f00;float:left;'></div></td>
<td>&nbsp</td>
</tr>
<th>{$lang.label_inv_content}</th>
<td>
  <select id='inv_input_v7' name='inv_content'>
    <option value=''>{$lang.please_select}</option>
    {foreach item=item key=key from=$cfg.invoice_content}
    <option value='{$item}' {if $item eq $order.inv_content}selected='selected'{/if}>{$item}</option>
    {/foreach}
  </select>
</td>
<td>&nbsp</td>
<tr>
<th>{$lang.label_inv_consignee_name}</th>
<td><input id='inv_input_v8' name='inv_consignee_name' value='{$order.inv_consignee_name}'/></td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_inv_consignee_phone}</th>
<td><input id='inv_input_v9' name='inv_consignee_phone' value='{$order.inv_consignee_phone}' onblur='javascript:check_phone_number(this,"phone_number_notice")' style='float:left;'/>
<div id='phone_number_notice' style='font-size:12px;color:#f00;float:left;'></div></td>
<td>&nbsp</td>
</tr>
<tr>
<th>收票人省份：</th>
<td>
<select name="inv_consignee_province" id="selProvinces" onChange="region.changed(this, 2, 'selCities')" style='width:70px;'>
  <option value="0">{$lang.select_please}</option>
  {foreach from=$order.inv_consignee_regions.inv_consignee_province_list item=province}
  <option value="{$province.region_id}" {if $order.inv_consignee_province eq $province.region_id}selected{/if}>{$province.region_name}</option>
  {/foreach}
</select>
<select name="inv_consignee_city" id="selCities" onchange="region.changed(this, 3, 'selDistricts')" style='width:70px;'>
  <option value="0">{$lang.select_please}</option>
  {foreach from=$order.inv_consignee_regions.inv_consignee_city_list item=city}
  <option value="{$city.region_id}" {if $order.inv_consignee_city eq $city.region_id}selected{/if}>{$city.region_name}</option>
  {/foreach}
</select>
<select name="inv_consignee_district" id="selDistricts" style='width:70px;'>
  <option value="0">{$lang.select_please}</option>
  {foreach from=$order.inv_consignee_regions.inv_consignee_district_list item=district}
  <option value="{$district.region_id}" {if $order.inv_consignee_district eq $district.region_id}selected{/if}>{$district.region_name}</option>
  {/foreach}
</select>
</td>
<td>&nbsp</td>
</tr>
<tr>
<th>{$lang.label_inv_consignee_address}</th>
<td><input id='inv_input_v10' name='inv_consignee_address' size='30' value='{$order.inv_consignee_address}'/></select></td>
<td>&nbsp</td>
</tr>
</tbody>
<tr>
<th colspan='2' align='center'><div style='height:30px;'>
<input class='button' type='submit' value='确定' style='margin-top:5px;'/>
<input class='button' type='button' value='取消' onclick='javascript:history.back()' style='margin-top:5px;'/>
</th>
<td>&nbsp</td>
</tr>
</table>
</div>
</form>
<!--查看增值税发票-->
{elseif $step_detail eq 'info'}
{if $order.inv_type eq 'vat_invoice'}
{if $order.inv_status eq 'provided'}
<form id='invocie_form' name="theForm" action="order.php?act=unprovide_invoice&act_from=invoice_info&order_id={$order.order_id}&order_sns={$order.order_sn}" method="post">
{else}
<form id='invocie_form' name="theForm" action="order.php?act=provide_invoice&act_from=invoice_info&order_id={$order.order_id}&order_sns={$order.order_sn}" method="post">
{/if}
<div class='list-div'>
<table width='100%' cellspacing='1'>
<tbody id='order_info_tbody'>
<tr><th colspan='4'><strong>{$lang.order_info}</strong></td><td colspan='2'>&nbsp</td></tr>
<tr>
<td align='right' width='13%'>{$lang.label_order_sn}</td>
<td width='20%'>{$order.order_sn}</td>
<td align='right' width='13%'>{$lang.label_order_time}</td>
<td width='20%'>{$order.order_time}</td>
<td colspan='2'></td>
</tr>
</tbody>
<tbody id='inv_info_tbody'>
<tr><th colspan='4'><strong>{$lang.inv_info}</strong></td><td colspan='4'>&nbsp</td></tr>
<td align='right'>{$lang.label_inv_type}</td>
<td>{$lang[$order.inv_type]}</td>
<td align='right'>{$lang.label_inv_content}</td>
<td>{$order.inv_content}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_company_name1}</td>
<td>{$order.vat_inv_company_name}</td>
<td align='right'>{$lang.label_taxpayer_id}</td>
<td>{$order.vat_inv_taxpayer_id}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_registration_address}</td>
<td>{$order.vat_inv_registration_address}</td>
<td align='right'>{$lang.label_registration_phone}</td>
<td>{$order.vat_inv_registration_phone}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_deposit_bank}</td>
<td>{$order.vat_inv_deposit_bank}</td>
<td align='right'>{$lang.label_bank_account}</td>
<td>{$order.vat_inv_bank_account}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right' width='13%'>{$lang.label_inv_money}</td>
<td width='20%'>{$order.formatted_inv_money}</td>
<td colspan='4'>&nbsp</td>
</tr>
</tbody>
<tbody id='inv_consignee_info_tbody'>
<tr><th colspan='4'><strong>{$lang.inv_consignee_info}</strong></td><td colspan='4'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_inv_consignee_name}</td>
<td>{$order.inv_consignee_name}</td>
<td align='right'>{$lang.label_inv_consignee_phone}</div></td>
<td>{$order.inv_consignee_phone}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_inv_consignee_address}</td>
<td>{$order.inv_complete_address}</td>
<td colspan='4'>&nbsp</td>
<tr>
<td align='right'>{$lang.label_action_note2}</td>
<td colspan='3'><textarea id='inv_remark' name='inv_remark' type='text' style='height:150px;width:98%;border:none;'>{$order.inv_remark}</textarea></td>
<td colspan='2'>&nbsp</td>
</tr>
</tbody>
<tr>
<th colspan='4' align='center'><div style='height:30px;'>
{if $order.inv_status eq 'provided'}
<input class='button' type='submit' value='取消开票' style='margin-top:5px;'/>
{else}
<input class='button' type='submit' value='开票' style='margin-top:5px;'/>
{/if}
</th>
<th colspan='2' >&nbsp</th>
</tr>
</table>
</div>
</form>
<!--查看普通发票-->
{elseif $order.inv_type eq 'normal_invoice'}
{if $order.inv_status eq 'provided'}
<form id='invocie_form' name="theForm" action="order.php?act=unprovide_invoice&act_from=invoice_info&order_id={$order.order_id}&order_sns={$order.order_sn}" method="post">
{else}
<form id='invocie_form' name="theForm" action="order.php?act=provide_invoice&act_from=invoice_info&order_id={$order.order_id}&order_sns={$order.order_sn}" method="post">
{/if}
<div class='list-div'>
<table width='100%' cellspacing='1'>
<tbody id='order_info_tbody'>
<tr><th colspan='4'><strong>{$lang.order_info}</strong></th><td colspan='2'>&nbsp</td></tr>
<tr>
<td align='right' width='13%'>{$lang.label_order_sn}</td>
<td width='20%'>{$order.order_sn}</td>
<td align='right' width='13%'>{$lang.label_order_time}</td>
<td width='20%'>{$order.order_time}</td>
<td colspan='2'>&nbsp</td>
</tr>
</tbody>
<tbody id='inv_info_tbody'>
<tr><th colspan='4'><strong>{$lang.inv_info}</strong></th><td colspan='2'>&nbsp</td></tr>
</tr>
<td align='right'>{$lang.label_inv_type}</td>
<td>{$lang[$order.inv_type]}</td>
<td align='right'>{$lang.label_inv_payee}</td>
<td>{$order.inv_payee}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_inv_content}</td>
<td>{$order.inv_content}</td>
<td align='right'>{$lang.label_inv_money}</td>
<td>{$order.formatted_inv_money}</td>
<td colspan='2'>&nbsp</td>
</tr>
</tbody>
<tbody id='inv_consignee_info_tbody'>
<tr><th colspan='4'><strong>{$lang.inv_consignee_info}</strong></th><td colspan='2'>&nbsp</td></tr>
<tr>
<td align='right'>{$lang.label_inv_consignee_name}</td>
<td>{$order.consignee}</td>
<td align='right'>{$lang.label_inv_consignee_phone}</td>
<td>{$order.mobile}</td>
<td colspan='2'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_inv_consignee_address}</td>
<td>{$order.inv_complete_address}</td>
<td colspan='4'>&nbsp</td>
</tr>
<tr>
<td align='right'>{$lang.label_action_note2}</td>
<td colspan='3'><textarea id='inv_remark' name='inv_remark' type='text' style='height:150px;width:98%;border:none;'>{$order.inv_remark}</textarea></td>
<td colspan='2'>&nbsp</td>
</tr>
</tbody>
<tr>
<th colspan='4' align='center'>
{if $order.inv_status eq 'provided'}
<input class='button' type='submit' value='取消开票' style='margin-top:5px;'/>
{else}
<input class='button' type='submit' value='开票' style='margin-top:5px;'/>
{/if}
</th>
<th colspan='2'>&nbsp</th>
</tr>
</table>
</div>
</form>
{/if}
<script language='javascript' type='text/javascript'>
var origin_inv_remark = '{$order.inv_remark}';
$('inv_remark').onblur=function(){
  if($('inv_remark').value != origin_inv_remark)
  {
    Ajax.call('?act=save_inv_remark','order_id='+{$order.order_id}+'&inv_remark='+$('inv_remark').value,save_inv_remark_response,'GET','POST',false,true);
  }
}
function save_inv_remark_response(result)
{
  if(result.error == '1')
  {
    alert('保存失败\n'+result.msg);
  }
  else
  {
    origin_inv_remark = $('inv_remark').value;
    alert('保存成功');
  }
}
</script>
{/if}
<!--增值税发票_添加_END_www.68ecshop.com-->
{/if}

<script language="JavaScript">
  var step = '{$step}';
  var orderId = {$order_id};
  var act = '{$smarty.get.act}';
{literal}
  function checkUser()
  {
    var eles = document.forms['theForm'].elements;

    /* 如果搜索会员，检查是否找到 */
    if (document.getElementById('user_useridname').checked && eles['user'].options.length == 0)
    {
      alert(pls_search_user);
      return false;
    }
    return true;
  }

  function checkGoods()
  {
    var eles = document.forms['theForm'].elements;

    if (eles['goods_count'].value <= 0)
    {
      alert(pls_search_goods);
      return false;
    }
    return true;
  }

  function checkConsignee()
  {
    var eles = document.forms['theForm'].elements;

    if (eles['country'].value <= 0)
    {
      alert(pls_select_area);
      return false;
    }
    if (eles['province'].options.length > 1 && eles['province'].value <= 0)
    {
      alert(pls_select_area);
      return false;
    }
    if (eles['city'].options.length > 1 && eles['city'].value <= 0)
    {
      alert(pls_select_area);
      return false;
    }
    if (eles['district'].options.length > 1 && eles['district'].value <= 0)
    {
      alert(pls_select_area);
      return false;
    }
	if ((eles['mobile'].value=="") && (eles['tel'].value=="")) {
		alert("手机号和电话至少填一项！");
		return false;
	} else {
		var msg="";
		if ((eles['mobile'].value!="") && !checkPhone(eles['mobile'].value)) {
			msg="手机号格式不正确！\n";
		}
		if ((eles['tel'].value!="") && !checkTel(eles['tel'].value)) {
			msg+="电话号格式不正确！";
		}
		if(msg!=""){
			alert(msg);
			return false;
		}
		
	}
    validator = new Validator("theForm");
    validator.required("consignee",  "收货人为空！");
    validator.required("email",  "电子邮件为空！");
    validator.required("address",  "地址为空！");
   // validator.required("tel",  "电话为空！");
    validator.isEmail("email",  "请输入有效邮件地址！");
   // validator.isMobile("tel",  "请输入有效电话！");
    return validator.passed();
  }
  function checkTel( tel )
  {
    var reg = /^[\d|\-|\s|\_]+$/; //只允许使用数字-空格等
    reg = /^(0[0-9]{2,3}-)?([0-9]{6,7})+(-[0-9]{1,4})?$/;
    return reg.test( tel );
  }
  function checkPhone( mobile )
  {
  	var reg = /^1\d{10}$/; //11位数字，以1开头。
  	return reg.test( mobile );
  }
  function checkShipping()
  {
    if (!radioChecked('shipping'))
    {
      alert(pls_select_shipping);
      return false;
    }
    return true;
  }

  function checkPayment()
  {
    if (!radioChecked('payment'))
    {
      alert(pls_select_payment);
      return false;
    }
    return true;
  }

  /**
   * 返回某 radio 是否被选中一个
   * @param string radioName
   */
  function radioChecked(radioName)
  {
    var eles = document.forms['theForm'].elements;

    for (var i = 0; i < eles.length; i++)
    {
      if (eles[i].name == radioName && eles[i].checked)
      {
        return true;
      }
    }
    return false;
  }

  /**
   * 按用户编号或用户名搜索用户
   */
  function searchUser()
  {
    var eles = document.forms['theForm'].elements;

    /* 填充列表 */
    var idName = Utils.trim(eles['keyword'].value);
    if (idName != '')
    {
      Ajax.call('order.php?act=search_users&id_name=' + idName, '', searchUserResponse, 'GET', 'JSON');
    }
  }

  function searchUserResponse(result)
  {
    if (result.message.length > 0)
    {
      alert(result.message);
    }

    if (result.error == 0)
    {
      var eles = document.forms['theForm'].elements;

      /* 清除列表 */
      var selLen = eles['user'].options.length;
      for (var i = selLen - 1; i >= 0; i--)
      {
        eles['user'].options[i] = null;
      }
      var arr = result.userlist;
      var userCnt = arr.length;

      for (var i = 0; i < userCnt; i++)
      {
        var opt = document.createElement('OPTION');
        opt.value = arr[i].user_id;
        opt.text = arr[i].user_name;
        eles['user'].options.add(opt);
      }
    }
  }

  /**
   * 按商品编号或商品名称或商品货号搜索商品
   */
  function searchGoods()
  {
    var eles = document.forms['goodsForm'].elements;

    /* 填充列表 */
    var keyword = Utils.trim(eles['keyword'].value);
    if (keyword != '')
    {
      Ajax.call('order.php?act=search_goods&keyword=' + keyword, '', searchGoodsResponse, 'GET', 'JSON');
    }
  }

  function searchGoodsResponse(result)
  {
    if (result.message.length > 0)
    {
      alert(result.message);
    }

    if (result.error == 0)
    {
      var eles = document.forms['goodsForm'].elements;

      /* 清除列表 */
      var selLen = eles['goodslist'].options.length;
      for (var i = selLen - 1; i >= 0; i--)
      {
        eles['goodslist'].options[i] = null;
      }

      var arr = result.goodslist;
      var goodsCnt = arr.length;
      if (goodsCnt > 0)
      {
        for (var i = 0; i < goodsCnt; i++)
        {
          var opt = document.createElement('OPTION');
          opt.value = arr[i].goods_id;
          opt.text = arr[i].name;
          eles['goodslist'].options.add(opt);
        }
        getGoodsInfo(arr[0].goods_id);
      }
      else
      {
        getGoodsInfo(0);
      }
    }
  }

  /**
   * 取得某商品信息
   * @param int goodsId 商品id
   */
  function getGoodsInfo(goodsId)
  {
    if (goodsId > 0)
    {
      Ajax.call('order.php?act=json&func=get_goods_info', 'goods_id=' + goodsId, getGoodsInfoResponse, 'get', 'json');
    }
    else
    {
      document.getElementById('goods_name').innerHTML = '';
      document.getElementById('goods_sn').innerHTML = '';
      document.getElementById('goods_cat').innerHTML = '';
      document.getElementById('goods_brand').innerHTML = '';
      document.getElementById('add_price').innerHTML = '';
      document.getElementById('goods_attr').innerHTML = '';
    }
  }
  function getGoodsInfoResponse(result)
  {
    var eles = document.forms['goodsForm'].elements;

    // 显示商品名称、货号、分类、品牌
    document.getElementById('goods_name').innerHTML = result.goods_name;
    document.getElementById('goods_sn').innerHTML = result.goods_sn;
    document.getElementById('goods_cat').innerHTML = result.cat_name;
    document.getElementById('goods_brand').innerHTML = result.brand_name;

    // 显示价格：包括市场价、本店价（促销价）、会员价
    var priceHtml = '<input type="radio" name="add_price" value="' + result.market_price + '" />市场价 [' + result.market_price + ']<br />' +
      '<input type="radio" name="add_price" value="' + result.goods_price + '" checked />本店价 [' + result.goods_price + ']<br />';
    for (var i = 0; i < result.user_price.length; i++)
    {
      priceHtml += '<input type="radio" name="add_price" value="' + result.user_price[i].user_price + '" />' + result.user_price[i].rank_name + ' [' + result.user_price[i].user_price + ']<br />';
    }
    priceHtml += '<input type="radio" name="add_price" value="user_input" />' + input_price + '<input type="text" name="input_price" value="" /><br />';
    document.getElementById('add_price').innerHTML = priceHtml;

    // 显示属性
    var specCnt = 0; // 规格的数量
    var attrHtml = '';
    var attrType = '';
    var attrTypeArray = '';
    var attrCnt = result.attr_list.length;
    for (i = 0; i < attrCnt; i++)
    {
      var valueCnt = result.attr_list[i].length;

      // 规格
      if (valueCnt > 1)
      {
        attrHtml += result.attr_list[i][0].attr_name + ': ';
        for (var j = 0; j < valueCnt; j++)
        {
          switch (result.attr_list[i][j].attr_type)
          {
            case '0' :
            case '1' :
              attrType = 'radio';
              attrTypeArray = '';
            break;

            case '2' :
              attrType = 'checkbox';
              attrTypeArray = '[]';
            break;
          }
          attrHtml += '<input type="' + attrType + '" name="spec_' + specCnt + attrTypeArray + '" value="' + result.attr_list[i][j].goods_attr_id + '"';
          if (j == 0)
          {
            attrHtml += ' checked';
          }
          attrHtml += ' />' + result.attr_list[i][j].attr_value;
          if (result.attr_list[i][j].attr_price > 0)
          {
            attrHtml += ' [+' + result.attr_list[i][j].attr_price + ']';
          }
          else if (result.attr_list[i][j].attr_price < 0)
          {
            attrHtml += ' [-' + Math.abs(result.attr_list[i][j].attr_price) + ']';
          }
        }
        attrHtml += '<br />';
        specCnt++;
      }
      // 属性
      else
      {
        attrHtml += result.attr_list[i][0].attr_name + ': ' + result.attr_list[i][0].attr_value + '<br />';
      }
    }
    eles['spec_count'].value = specCnt;
    document.getElementById('goods_attr').innerHTML = attrHtml;
  }

  /**
   * 把商品加入订单
   */
  function addToOrder()
  {
    var eles = document.forms['goodsForm'].elements;

    // 检查是否选择了商品
    if (eles['goodslist'].options.length <= 0)
    {
      alert(pls_search_goods);
      return false;
    }
    return true;
  }

  /**
   * 载入收货地址
   * @param int addressId 收货地址id
   */
  function loadAddress(addressId)
  {
{/literal}
    location.href += 'order.php?act={$smarty.get.act}&order_id={$smarty.get.order_id}&step={$smarty.get.step}&address_id=' + addressId;
{literal}
  }
</script>
{/literal}

{include file="pagefooter.htm"}